package com.framework.yhbapi.controller;

import com.framework.exception.util.RespResult;
import com.framework.service.yhbservice.ValidateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("validate")
@Api(value="验证接口" ,tags={"验证接口"})
public class ValidateController {
    @Autowired
    private ValidateService validateService;

    /**
     * 验证sn
     * @param sn
     * @param deptId
     * @return
     */
    @PostMapping(value = "/validateSn")
    @ApiOperation("验证Sn")
    @ApiImplicitParams({
        @ApiImplicitParam(name="sn",value = "机器sn",paramType = "string" ,required = true),
        @ApiImplicitParam(name="deptId",value = "渠道id，用户宝默认传2",paramType = "string" ,required = true),
        @ApiImplicitParam(name="terminalType",value = "终端类型",paramType = "integer" ,required = true)
    })
    private RespResult validateSn(String sn,Long deptId,Integer terminalType){
        Map<String,Object> map = validateService.validateSn(sn,deptId,terminalType);
        return RespResult.ok(map);
    }
    /**
     * 验证商户识别号
     * @param merCode
     * @return
     */
    @PostMapping(value = "/validatemerCode")
    @ApiOperation("验证商户识别号")
    @ApiImplicitParams({
            @ApiImplicitParam(name="merCode",value = "商户识别号",paramType = "string" ,required = true),
            @ApiImplicitParam(name="merCode",value = "商户识别号",paramType = "string" )
    })
    private RespResult validatemerCode(String merCode,String phone){
        Boolean flag = validateService.validatemerCode(merCode,phone);
        return RespResult.ok().put("flag",flag);
    }

}
